<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.net.*" %>
<%@include file="../../../tools/commonTag.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>资源分配</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" href="${path}/style/backui/system.css">
		<script src="${path}/js/jquery-1.6.js"></script>
		<script src="${path}/js/backjs/sysutil.js"></script>
		<script src="${path}/js/backjs/tree_func.js"></script>
		<script type="text/javascript">getPath("<%=request.getContextPath()%>") ;</script>
		<script type="text/javascript">
			function checkeds(index) {
				var s = $("input:[name=resource"+index+"]") ;
				if(s.is(":checked")) {
					s.attr("checked","");
				} else {
					s.attr("checked","checked");
				}
			}

			function getCheckVal() {
				var sval = $("input:checked") ;

				var selVal = $("#role") ;

				var role_res = "" ;
				
				if("un" != selVal.val()) {
					if(undefined != sval && sval.length > 0) {
						var appendID = "";
						sval.each(function(){
							var sv = $(this) ;
							appendID += sv.val() + "," ;
						});
						appendID = appendID.substring(0,appendID.length-1) ;

						role_res = selVal.val()+"&"+appendID ;
						
						//alert(role_res) ;

						window.location.href="${path}/privilegeRole!updateRoleAssignRes.action?rolevo.r_id="+selVal.val()+"&resourceIds="+appendID;
					} else {
						alert("未选择资源") ;
					}
				} else {
					alert("未选择角色") ;
				}
			}
		</script>
	</head>

	<body>
		<div id="main">
			<div id="page_body">
				<div class="page_title">
					
				</div>
				<div class="page_content">
					<c:forEach var="ms" items="${model}" varStatus="v">
						<table class="TableList" width="95%" align="center">
							<tr class="TableHeader">
								<td colspan="2" style="text-align: left;" id="title">
									${ms.m_name }
								</td>
							</tr>
							<tr class="TableData">
								<td align="left" width=10%><a href="javascript:checkeds('${v.count}');">全选/反选</a></td>
								<td align="left" width="90%" style="float:left;display:table;">
									<c:forEach var="resItem" items="${ms.msrc}">
										<div style="width:150px;height:25px;float:left;">
											<input type="checkbox" name="resource${v.count}" value="${resItem.mc_id}"/>
											${resItem.mc_name}
										</div>
									</c:forEach>
								</td>
							</tr>
						</table>
						<br/>
					</c:forEach>
					<table class="TableList" width="95%" align="center">
						<tr class="TableControl">
								<td colspan="19" align="center">
									<select id="role">
										<option value="un" selected="selected">请选择角色</option>
										<c:forEach var="r" items="${role}">
											<option value="${r.r_id}">${r.r_name}</option>
										</c:forEach>
									</select>
								
									<input type="button" onclick="getCheckVal()" value="分配资源">
									
								</td>
						   </tr>
					</table>
				</div>
			</div>
		</div>
		
		<script type="text/javascript">
			var tb = $(".TableList") ;
			var title_tb = $(".small") ;
			title_tb.css("width",tb.attr("width")) ;
		</script>
	</body>
</html>
